package org.example.cloudcommon.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.cloudcommon.pojo.Student;

import java.util.List;

public interface StudentMapper extends BaseMapper<Student> {
    @Select("SELECT student.id , student.name" +
            " FROM student  WHERE age = #{age} AND name like CONCAT('%',#{name},'%')")
    List<Student> findAll(@Param(value = "age") int age, @Param(value = "name") String name);
    @Select("SELECT * FROM student  WHERE id = #{id}")
    Student findAllOne(@Param(value = "id") Integer id);
    @Select("SELECT * FROM student  WHERE id = #{id} AND name like CONCAT('%',#{name},'%')")
    List<Student> findAllById(@Param(value = "id") Integer id, @Param(value = "name") String name);
    @Delete("DELETE FROM student WHERE id = #{id}")
    void deleteStudentById(@Param(value = "id") Integer id);

    @Update("UPDATE student SET name = #{name} WHERE id = #{id}")
    void updateStudent(@Param(value = "id") Integer id,
                       @Param(value = "name") String name);
    @Insert("INSERT INTO student(id,name,sex,address,username,password,age) " +
            "VALUES (id = #{id},name = #{name},sex = #{sex},address = #{address},username = #{username},password = #{password},age = #{age})")
    void CreateStudent(Student student);

    List<Student> findByIdMapperXml(@Param("name") String name);

    List<Student> findByIdMapperXml2(@Param("id") int id);
}
